<?php

class Server extends ExtendedController {

    protected $functions = array(
        array(),
        array()
    );

    function __construct() {
        parent::__construct();
    }

    function index() {

        $this->user->server->get();

        $serverViews = array();

        foreach ($this->user->server as $server) {
            if (!Plugin::pluginExists($server->plugin)) {
                Plugin::registerPlugin($server->plugin);
            }

            

            $server->instance = new $server->plugin;
            $server->instance->name = "test";
            $serverViews[] = $server->instance->show();
        }

        var_dump($serverViews);

        //$this->installController(__CLASS__, 'Server');
        //Plugin::installPlugin('source');
        //var_dump(Plugin::getPlugins());

        $this->viewValues['header'] = array(
            'title' => 'Server'
        );
        $this->viewValues['body'] = array(
            'server' => $serverViews
        );
        $this->viewValues['footer'] = array(
        );
        
        //$this->loadViews(array('viewHeader', 'viewServer', 'viewFooter'), $this->viewValues);
    }

    function add() {

    }

    function delete ($id = null) {
        if(!is_null($id)) {
            
        }
    }
}